/**
* Created by lesonli on 2016/11/15.
*/
<template>
<div id="app">
    <router-view></router-view>
</div>
</template>

<script>
import api from './api/modules/config'
import {
  logout
} from './api/modules/auth';
import {
    mapState
} from 'vuex'
import { Loading } from 'element-ui';
export default {
    data() {
        return {
            loadingInstance:null
        }
    },
    computed: {
       
    },
    beforeCreate() {
        var vm = this;
        api.interceptors.request.use(function(config) {
            // Do something before request is sent
            if (config.data) {
                config.data.token = '' || vm.$localStorage.get('token');
            }

            return config;
        }, function(error) {
            // Do something with request error
            return Promise.reject(error);
        });
        api.interceptors.response.use(function(response) {
            // Do something with response data
            if (response.data.res_code < 0) {
                    if(response.data.res_code >= -999 &&  response.data.res_code <= -995)
                    {
                        vm.$router.push({
                            path: '/login'
                        });
                    }
                    else if (response.data.res_code == -6) {
                        vm.$router.push({
                            path: '/login'
                        });
                    } else {
                        if(response.config.url.indexOf('student/hasStudent') < 0)
                        {
                            vm.$alert(response.data.msg, '提示', {
                            confirmButtonText: '确定',
                            callback: action => {}
                        });
                        }           
                    }
            }
            return response;
        }, function(error) {
            // Do something with response error
            return Promise.reject(error);
        });
        // if (vm.$route.name !== 'login')
        //     this.$store.dispatch('get_user_info');
    },
    mounted() {
        
    },
    watch: {
        
    }
}
</script>
<style lang="scss">
html {
    height: 100%;
}

body {
    display: flex;
    //align-items: center;
    //ustify-content: center;
    //height: 100%;
    margin: 0;
}

#app {
    color: #2c3e50;
    width: 100%;
    padding: 0;
    //margin-top: -100px;
    //max-width: 600px;
    //font-family: Source Sans Pro, Helvetica, sans-serif;
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    text-align: center;
    a {
        //color: #42b983;
        text-decoration: none;
    }

    .el-dialog {
        border-radius: 10px;
        .el-dialog__header {
            border-radius: 10px 10px 0 0;
            background-color: #546573;
            padding: 20px;
            .el-dialog__title {
                color: #ffffff;
            }
        }
    }

    .el-breadcrumb {
        .el-breadcrumb__item {
            .el-breadcrumb__item__inner {
                color: #2E3E47;
            }
            &:last-child {
                .el-breadcrumb__item__inner {
                    color: #8B9FA9;
                }
            }
        }
    }
}

.sub-header {
    margin: 20px;
}
</style>
